package com.weather.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.weather.service.CityDataService;
import com.weather.service.WeatherReportService;

/**
 * @Description WeatherReport Controller
 *
 * @author 堆堆堆
 * @date 2018年5月31日 上午10:05:26
 */
@Controller
@RequestMapping("/report")
public class WeatherReportController {

	@Autowired
	private WeatherReportService weatherReportService;

	@Autowired
	private CityDataService cityDataService;

	@GetMapping("/cityId/{cityId}")
	public String getReportByCityId(@PathVariable("cityId") String cityId, Model model) throws Exception {

		model.addAttribute("title", "老子的天气预报");
		model.addAttribute("cityId", cityId);
		model.addAttribute("cityList", cityDataService.listCity());
		model.addAttribute("report", weatherReportService.getDataByCityId(cityId));

		return "weather/report";
	}
}
